/*
 * Project Name: cms_manager
 * File Name: AdminService.java
 * Copyright: ZKTeco Corporation 2015
 * Description: TODO 请在此处添加对本文件的描述
 * Creator: Administrator
 * Create Date: 2015年1月28日 下午3:51:57
 */
package com.shishuo.cms.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import com.shishuo.cms.dao.AdminDao;
import com.shishuo.cms.dao.IBaseDAO;
import com.shishuo.cms.entity.Admin;
import com.shishuo.cms.entity.vo.PageVo;
import com.shishuo.cms.exception.BusinessException;
import com.shishuo.cms.util.AuthUtils;

@Service
public class AdminService extends BaseService<Admin,Long>
{
	 
	private AdminDao adminDao;
	
	@Autowired
    public void setAdminDao(AdminDao adminDao) {  
		super.setBaseDao(adminDao);
		this.adminDao=adminDao;
    }
	
	
	public Admin getAdminByEmail(String email) {
		return adminDao.getAdminByEmail(email);
	}
	public PageVo<Admin> getAllListPage(int pageNum) throws Exception{
		PageVo<Admin> pageVo = new PageVo<Admin>(pageNum);
		List<Admin> list = this
				.getAllList(pageVo.getOffset(), pageVo.getRows());
		pageVo.setList(list);
		pageVo.setCount(this.getAllListCount());
		return pageVo;
		//throw new BusinessException("业务异常");
	}


	public void save(Admin entity) throws Exception {
		entity.setPassword(AuthUtils.getPassword(entity.getPassword(), entity.getEmail()));
		insert(entity);
	}
}
